package com.ics.atable.chat.dispatcher;

import com.alibaba.cloud.ai.graph.OverAllState;
import com.alibaba.cloud.ai.graph.action.EdgeAction;
import lombok.extern.slf4j.Slf4j;

import static com.alibaba.cloud.ai.graph.StateGraph.END;
import static com.ics.atable.chat.constant.ItemQueryConstant.*;

/**
 * @author wangbohan
 * 判断类
 */
@Slf4j
public class IntentDispatcher implements EdgeAction {

    @Override
    public String apply(OverAllState state) {

        Integer feedbackObj = state.value(FEED_BACK_COUNT, 0);
        log.info("feedbackCount_dispatcher: {}", feedbackObj);

        // 判断反馈次数
        if (feedbackObj > 5){
            return END;
        }
        else{
            return state.value(INTENT_NEXT_NODE, STRUCT_TOKEN);
        }


    }
}
